<html>
<head>
<script type="text/javascript">
 function msgBox(message)
 {
  var msgbox = document.getElementById("msgbox");
  msgbox.innerHTML = message;
  var x = (window.innerWidth / 2) - (msgbox.offsetWidth / 2);
  var y = (window.offsetHeight / 2) - (msgbox.offsetHeight / 2);              
  msgbox.style.top = y;
  msgbox.style.left = x;
  msgbox.style.display = "block";
 }
 
</script>
<style>
 #msgbox
 {
  position: absolute;
  margin: auto;
  padding: 12px;
  left: 0px;
  top: 0px;
  display: none;
  color: white;
  background-color: lightgray;
 }
</style>
</head>
<body>
<div id="msgbox">&nbsp;</div>
<br><br><br>
<input type="button" value="Click me!" onclick="msgBox('Are you sure you want to do this?');">
</body>
</html>